Conditions | 2 |
Total Lines | 18 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import {QueryHandler} from '@nestjs/cqrs'; |
||
15 | |||
16 | public async execute(query: GetCustomerByIdQuery): Promise<CustomerView> { |
||
17 | const customer = await this.customerRepository.findOneById(query.id); |
||
18 | if (!customer) { |
||
19 | throw new CustomerNotFoundException(); |
||
20 | } |
||
21 | |||
22 | const address = customer.getAddress(); |
||
23 | |||
24 | return new CustomerView( |
||
25 | customer.getId(), |
||
26 | customer.getName(), |
||
27 | new AddressView( |
||
28 | address.getId(), |
||
29 | address.getStreet(), |
||
30 | address.getCity(), |
||
31 | address.getZipCode(), |
||
32 | address.getCountry() |
||
33 | ) |
||
37 |